package demo.router;

import demo.service.HelloWorldServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
import org.springframework.web.reactive.function.server.RequestPredicates;
import org.springframework.web.reactive.function.server.RouterFunction;
import org.springframework.web.reactive.function.server.RouterFunctions;
import org.springframework.web.reactive.function.server.ServerResponse;

/**
 * @author wangyang
 * email:techyang.wangy@ymm56.com
 * company: 运满满
 * Created on 2018/8/15.
 */
@Configuration
public class HelloWorldRouter {

    @Bean
    public RouterFunction<ServerResponse> routeHello(@Autowired HelloWorldServiceImpl helloWorldServiceImpl) {
        return RouterFunctions

                .route(RequestPredicates.GET("/hello")
                                .and(RequestPredicates.accept(MediaType.TEXT_PLAIN)),
                        helloWorldServiceImpl::helloCity);
    }

}
